<extend name="Base/common" />
<block name="body">
	<!--导航引用-->
	<include file="Public/nav" />
	
	<section class="ui-container">
		<div class="ui-confirm-successful">
			<div class="ui-whitespace">
				<div class="ui-confirm-successful-info">
					<p><b>订单编号：</b><small>{$row.order_id}</small></p>
					<p><b>下单时间：</b><small>{$row.ctime|time_format=###,'Y-m-d H:i:s'}</small></p>
					<p>
						<b>收货地址：</b><small>{$row.name}&nbsp;&nbsp;<span>{$row.phone}</span></small><br />
						<small>{$row.pro_id|getAreaName=###} {$row.city_id|getAreaName=###} {$row.area_id|getAreaName=###} {$row.address}</small>
					</p>
				</div>
				<small class="ui-txt-info">
					如对订单有何疑问，请联系客服进行解决！<br />
					<font color='red'>客服电话：{:getCustomPhone()}</font>
				</small>
				<div class="ui-warning">
					<b>安全提醒：</b>
		        	<p>下单后，为了您的财产安全，任何有涉及批发、汇款、退款等内容的信息或电话，请不要相信，谨防假冒客服电话诈骗！</p>
				</div>
			</div>
        </div>
		<div class="ui-list-pay-state">
			<h5 class="ui-title">
				<b>订单号：</b><small>{$row.order_id}</small>
				<b class="ui-txt-highlight">
					<notempty name="row.return_status">
						<switch name="row.return_status">
							<case value="2">审核中...</case>
							<case value="3">审核通过</case>
							<case value="4">审核未通过</case>
							<case value="5">退货中</case>
							<case value="6">厂家已收货</case>
							<case value="7">退款中</case>
							<case value="8">退款完成</case>
							<case value="9">取消退款</case>
							<case value="10">用户撤销</case>
						</switch>
					<else />
						<switch name="row.order_status">
							<case value="0">等待买家付款</case>
							<case value="1">付款确认中</case>
							<case value="2">买家已付款</case>
							<case value="3">卖家已发货</case>
							<case value="4">交易成功</case>
							<case value="5">交易关闭</case>
							<case value="6">交易完成</case>
						</switch>
					</notempty>
				</b>
			</h5>
			<ul class="ui-list-goods-cart ui-whitespace ui-border-tb">
				<volist name="list" id="vo">
					<li class="ui-tiled ui-border-b">
						<div class="ui-list-goods-img">
				            <img src="{$vo.picture||get_cover='path'}" width="50" height="50"/>
				        </div>
				        <div class="ui-list-goods-info">
				        	<h5>{$vo.name}</h5>
				        	<p class="ui-goods-size-color"><span>数量：{$vo.num}</span></p>
				        </div>
				        <div class="ui-list-goods-price">
				        	<p class="price">
				        		<b>￥{$vo.price}</b>
				        		<del>{$vo.shop_price}</del>
				        	</p>
				        </div>
					</li>
				</volist>
			</ul>
			<div class="ui-pay-state-btn">
				<div class="ui-btn-group ui-flex-pack-end">
					<switch name="row.order_status">
						<case value="0">
							<a href="#" class="ui-btn-s ui-btn-primary paynow"  pock-money="{$row.pock_money}" zk="{$row.zhekouAll}" order="{$row.order_id}" shopid="{$data.shop_id}" user="{$data.user_id}">去支付</a>
							<a href="#" class="ui-btn-s ui-btn-danger cancel_order" dorder="{$row.order_id}">取消订单</a>
						</case>
						<case value="1"></case>
						<case value="2"></case>
						<case value="3">
							<a href="#" class="ui-btn-s ui-btn-primary shouhuo" d_order_id="{$row.order_id}">确认收货</a>
						</case>
						<case value="4">
							<eq name="row.is_take" value="0">
								<if condition="$row.return_status eq 2">
									<a href="{:U('ReturnGoods/return_info', array('return_order_id' => $row['return_order_id']))}" class="ui-btn-s ui-btn-primary">审核中...</a>
								<elseif condition="$row.return_status eq 3"/>
									<a href="{:U('ReturnGoods/sureVerify', array('return_order_id' => $v['return_order_id']))}" class="ui-btn-s ui-btn-primary">审核完成</a>
								<elseif condition="$row.return_status eq 4"/>
									<a href="{:U('ReturnGoods/sureVerify', array('return_order_id' => $v['return_order_id']))}" class="ui-btn-s ui-btn-primary">审核未通过</a>
								<elseif condition="$row.return_status eq 5"/>
								<elseif condition="$row.return_status eq 6"/>
								<elseif condition="$row.return_status eq 7"/>
								<elseif condition="$row.return_status eq 8"/>
								<elseif condition="$row.return_status eq 9"/>
								<elseif condition="$row.return_status eq 10"/>
								<else />
									<a _href="{:U('ReturnGoods/index', array('order_id' => $row['order_id'], 'type' => 'ALL', 'return_money' => $row['pock_money']))}" class="ui-btn-s ui-btn-primary user_return_goods">申请退货</a>
									<a href="javascript::" class="ui-btn-s ui-btn-danger sure_not_goods" d_order_id="{$row.order_id}">确认不退货</a>
								</if>
							</eq>
						</case>
					</switch>
					<a href="http://m.kuaidi100.com/index_all.html?type={$row.wl_name|getCompanyCode=###}&postid={$row.wl_order}&callbackurl=javascript:history.go(-1);" class="ui-btn-s ui-btn-primary">查看物流</a>
				</div>
			</div>	
		</div>
		<div class="ui-actionsheet">  
		  <div class="ui-actionsheet-cnt">
		    <h4>请选择取消订单的理由</h4> 
		    <button>我不想买了</button>  
		    <button>信息填写错误，重新拍</button>  
		    <button>卖家缺货</button>  
		    <button>面对面交易</button>  
		    <button>其他原因</button>  
		    <button>取消</button> 
		  </div>         
		</div>
	</section>
</block>
<block name="script">
	<script type="text/javascript">
		var order_id = '';
		//取消订单
		$('.cancel_order').click(function(){
			order_id = '';
			order_id = $(this).attr('dorder');
			$('.ui-actionsheet').addClass('show');
		});

		$('.ui-actionsheet div button').click(function(){
			var return_msg = $(this).html();
			if(return_msg=='取消'){
				$('.ui-actionsheet').removeClass('show');
			}else{
				$.get("{:U('cancel_order')}", {
					order_id: order_id,
					return_msg: return_msg
				}, function(r) {
					if (r.status) {
						$.tips({
					        content:'取消订单成功！',
					        stayTime:2000,
					        type:"success"
					    });
						window.location.reload();
					} else {
						$.tips({
					        content:'服务器连接失败',
					        stayTime:2000,
					        type:"success"
					    });
					    $('.ui-actionsheet').removeClass('show');
					}
				}, 'json');
			}
		});

		//收货
		$('.shouhuo').click(function(){
			var order_id = $(this).attr('d_order_id');
			sureGoods(order_id, 0, '确认收货？');
			
		});
		//收货不退货
		$('.shouhuo_no_return').click(function(){
			var order_id = $(this).attr('order_id_no');
			sureGoods(order_id, 1, '确认收获不退货？');
		});
		
		function sureGoods(order_id, type, msg){
			var dia=$.dialog({
		        title:'温馨提示',
		        content: msg,
		        button:["确认","取消"]
		    });
		    dia.on("dialog:action",function(e){
		    	if(e.index == 0){
		    		$.ajax({
	                url: "{:U('sureGoods')}",
		                type: 'post',
		                data: {
		                    order_id: order_id,
		                    type: type
		                },
		                dataType: 'json',
		                error: function () {
		                    $.tips({
						        content:'服务器连接失败',
						        stayTime:2000,
						        type:"success"
						    });
		                }, success: function (data) {
		                    if (data.status) {
		                        $.tips({
							        content:data.info,
							        stayTime:2000,
							        type:"success"
							    });

		                        document.location.reload();//当前页面  
		                    } else {
		                        $.tips({
							        content:data.info,
							        stayTime:2000,
							        type:"success"
							    });

		                    }
		                }
		            });
		    	}
		       	
		    });
		    dia.on("dialog:hide",function(e){
		        console.log("dialog hide")
		    });
		}
		
		$('.sure_not_goods').tap(function(){
			var order_id = $(this).attr('d_order_id');
			var dia=$.dialog({
		        title:'温馨提示',
		        content: '确认不退货？',
		        button:["确认","取消"]
		    });
		    dia.on("dialog:action",function(e){
		    	if(e.index == 0){
		    		$.ajax({
		                url: "{:U('sureNotGoods')}",
		                type: 'get',
		                data: {
		                    order_id: order_id
		                },
		                dataType: 'json',
		               	success: function (data) {
		                    if (data.status) {
		                        $.tips({
							        content:data.info,
							        stayTime:2000,
							        type:"success"
							    });

		                        document.location.reload();//当前页面  
		                    } else {
		                        $.tips({
							        content:data.info,
							        stayTime:2000,
							        type:"success"
							    });

		                    }
		                }
		            });
		    	}
		       	
		    });
		    dia.on("dialog:hide",function(e){
		        console.log("dialog hide")
		    });
		});
		
		var browser={ 
		versions:function(){ 
			var u = navigator.userAgent, app = navigator.appVersion; 
			return { 
			trident: u.indexOf('Trident') > -1, //IE内核 
			presto: u.indexOf('Presto') > -1, //opera内核 
			webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核 
			gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核 
			mobile: !!u.match(/AppleWebKit.*Mobile.*/)||!!u.match(/AppleWebKit/), //是否为移动终端 
			ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 
			android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器 
			iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器 
			iPad: u.indexOf('iPad') > -1, //是否iPad 
			webApp: u.indexOf('Safari') == -1 //是否web应该程序，没有头部与底部 
			};
			}()
		}
		
		var temp_order = '';
		function __payNow(amount, discount, mall_orderId, shopId, userId) {
			temp_order = mall_orderId;
			//window.android.jsShopPayment(amount, discount, mall_orderId, shopId, userId);
			if(browser.versions.mobile&&browser.versions.ios&&browser.versions.iPhone||browser.versions.iPad){
				window.location.href = "js://" + encodeURIComponent('{"action":"pay","amount": "'+amount+'","discount":"'+discount+'","mall_orderId":"'+mall_orderId+'","shopId":"'+shopId+'","userId":"'+userId+'"}');
			}
			
			if(browser.versions.mobile&&browser.versions.android){
				window.android.jsShopPayment(amount, discount, mall_orderId, shopId, userId);
			}
	    }

	    $('.paynow').tap(function(){
	    	var amount = $(this).attr('pock-money'),
	    		discount = $(this).attr('zk'),
	    		mall_orderId = $(this).attr('order'),
	    		shopId = $(this).attr('shopid'),
	    		userId = $(this).attr('user');

	    	temp_order = mall_orderId;
			if(browser.versions.mobile&&browser.versions.ios&&browser.versions.iPhone||browser.versions.iPad){
				window.location.href = "js://" + encodeURIComponent('{"action":"pay","amount": "'+amount+'","discount":"'+discount+'","mall_orderId":"'+mall_orderId+'","shopId":"'+shopId+'","userId":"'+userId+'"}');
			}
			
			if(browser.versions.mobile&&browser.versions.android){
				window.wst.startFunction(amount, discount, mall_orderId, shopId, userId)
			}

	    });

		function onPayResultCallback(statusCode){
			if(statusCode == 0){
				var url = "{:U('PayBack/index')}";
				
				if( url.indexOf('?')>0 ){
					url += '&order_id=' + temp_order;
				}else{
					url += '?order_id=' + temp_order;
				}
				window.location.href = url;
			}else if(statusCode == 1){
				$.tips({
			        content:'支付失败！',
			        stayTime:2000,
			        type:"success"
			    });
			}else if(statusCode == 2){
				$.tips({
			        content:'用户取消',
			        stayTime:2000,
			        type:"success"
			    });
			}
		}

		$('.user_return_goods').tap(function(){
			var url = $(this).attr('_href');
			$.get("{:U('ReturnGoods/check_user_bank')}", function(r){
				if(r.status){
					window.location.href = url;
				}else{
					var dia=$.dialog({
						        title:'温馨提示',
						        content:'系统检测你还未绑定银行卡！',
						        button:["现在绑卡","取消"]
						    });

				    dia.on("dialog:action",function(e){
				        if( e.index == 0 ){
				        	//绑定银行卡
				        	window.location.href = "{:U('Member/bank_index')}";
				        }
				    });
				    dia.on("dialog:hide",function(e){
				        console.log("dialog hide")
				    });
				}
			}, 'json');
		});

		function goHome(){
			window.location.href='/index.php?s=/Home/Index/index/uid/{$_SESSION[userid]}';
		}
	</script>
</block>